texture gDiffuse;              // Color texture for mesh
float2 gPosition;

sampler DiffuseLinearSampler = 
sampler_state
{
    Texture = <gDiffuse>;
    MipFilter = LINEAR;
    MinFilter = LINEAR;
    MagFilter = LINEAR;
    AddressU = CLAMP;
    AddressV = CLAMP;
    SRGBTexture = TRUE;
};

//--------------------------------------------------------------------------------------
// Vertex shader output structure
//--------------------------------------------------------------------------------------
struct VS_OUTPUT
{
    float4 Position   : POSITION;   // vertex position
    float2 TextureUV  : TEXCOORD0;
};

VS_OUTPUT RenderSceneVS( float4 vPos : POSITION, 
                         float2 vTextureUV : TEXCOORD0 )
{
    VS_OUTPUT output;

	output.Position = vPos;
	output.Position.xy += gPosition.xy;
	output.TextureUV = vTextureUV;
    
    return output;
}


//--------------------------------------------------------------------------------------
// Pixel shader output structure
//--------------------------------------------------------------------------------------
struct PS_OUTPUT
{
    float4 RGBColor : COLOR0;  // Pixel color    
};


//--------------------------------------------------------------------------------------
// This shader outputs the pixel's color by modulating the texture's
//       color with diffuse material color
//--------------------------------------------------------------------------------------
PS_OUTPUT RenderScenePS( VS_OUTPUT In ) 
{ 
    PS_OUTPUT output;
    output.RGBColor = tex2D(DiffuseLinearSampler, In.TextureUV);
    if(output.RGBColor.a < 0.5f)
    {
		discard;
	}

    return output;
}


//--------------------------------------------------------------------------------------
// Renders scene to render target
//--------------------------------------------------------------------------------------
technique Render
{
    pass P0
    {          
        VertexShader = compile vs_3_0 RenderSceneVS();
        PixelShader  = compile ps_3_0 RenderScenePS(); // trivial pixel shader (could use FF instead if desired)
        
        SCISSORTESTENABLE = true;
    }
}
